<?php

$params = require(__DIR__ . '/params.php');

$config = [
   // 默认路由
    //'defaultRoute' => '/user/security/login',
    //维护模式，所有页面显示统一页面
    //'catchAll' => ['site/offline'],
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'language' => 'zh-CN',
    'modules' => [
     'rbac' => [
        'class' => 'dektrium\rbac\Module',
    ],
    'user' => [
        'class' => 'dektrium\user\Module',
        'modelMap' => [
        'User' => 'app\models\User',
    ],
        'enableUnconfirmedLogin' => true,
        'admins' => ['Hooley']
    ],
],
    'components' => [
        'authManager' => [   //加入这两行
            'class' => 'yii\rbac\DbManager'],
        'urlManager' => [
        'enablePrettyUrl' => true,
        'enableStrictParsing' => false,
        'showScriptName' => false,
         'rules' => [
            [
                'class' => 'yii\rest\UrlRule',
               // 'pluralize' => false,
                'controller' => ['car'],

                'extraPatterns' => ['POST search' => 'search',
                                    'POST bd'=>'bd',
                                    'POST gzxg'=>'gzxg',
                                    'POST jcbd'=>'jcbd',
                                  
                ],

            ],
            ],
             'rules' => [
            [
                'class' => 'yii\rest\UrlRule',
               // 'pluralize' => false,
                'controller' => ['order'],

                'extraPatterns' => ['POST search' => 'search',
                                    'POST tj'=>'tj',
                                    
                                    
                                  
                ],

            ],
            ],
             'rules' => [
            [
                'class' => 'yii\rest\UrlRule',
               // 'pluralize' => false,
                'controller' => ['app-user'],

                'extraPatterns' => ['POST register' => 'register',
                                    'POST login'=>'login',
                                    'POST del'=>'del',
                                    'POST xgmm'=>'xgmm',
                ],

            ],
            ]
        ],
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => '@#*dfa',
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
       // 'user' => [
    //   'identityClass' => 'app\models\User',
          //  'enableAutoLogin' => true,
    //    ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'useFileTransport' => true, //这句一定有，false发送邮件，true只是生成邮件在runtime文件夹下，不发邮件
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.163.com', //使用163邮件服务器
                'username' => '17707711856@163.com',
                'password' => '********', //此处隐去密码  
                'port' => '465', //端口一般都是465
                'encryption' => 'ssl', //协议一般都是ssl安全协议
            ],
            'messageConfig' => [
                'charset' => 'UTF-8',
                'from' => ['zfatgxu@163.com' => 'admin']
            ],
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'db' => require(__DIR__ . '/db.php'),
    ],
    'params' => $params,
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
    ];
}

return $config;
